<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateTabViewFieldsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('tab_view_fields', function (Blueprint $table) {
            $table->engine = 'InnoDB';
            $table->uuid ('id')->primary ('id');//uuid主键
            $table->uuid ('field_id');//字段id
            $table->uuid ('view_id');//字段id
            $table->timestamps();
            $table->foreign ('view_id')->references ('id')->on ('tab_views')->onDelete ('cascade');//视图外键
            $table->foreign ('field_id')->references ('id')->on ('fields')->onDelete ('cascade');//字段外键
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('tab_view_fields');
    }
}
